Skip to content

Conversation

@mikeleppane
Copy link
Contributor

Add three new MCP tools that enable AI assistants to configure Robocop through natural language. Users can describe what they want (e.g., "allow longer lines" or "disable naming checks") and the AI generates the appropriate TOML configuration.

New tools:

  • get_config_context: Provides rule catalog and instructions for LLM processing
  • parse_config_response: Validates LLM JSON response into config suggestions
  • apply_configuration: Writes validated config to TOML files

Key features:

  • Support for all config formats (pyproject.toml, robot.toml, robocop.toml)
  • Handles rule configuration, enable/disable, and scalar options
  • Multi-section support (common, lint, format)
  • Intelligent TOML merging preserving existing configuration
  • Conflict detection (e.g., enabling and disabling same rule)
  • Deprecated rule warnings
  • Preview-by-default workflow (apply_configuration is explicit)

Add three new MCP tools that enable AI assistants to configure Robocop
through natural language. Users can describe what they want (e.g., "allow
longer lines" or "disable naming checks") and the AI generates the
appropriate TOML configuration.

New tools:
- get_config_context: Provides rule catalog and instructions for LLM processing
- parse_config_response: Validates LLM JSON response into config suggestions
- apply_configuration: Writes validated config to TOML files

Key features:
- Support for all config formats (pyproject.toml, robot.toml, robocop.toml)
- Handles rule configuration, enable/disable, and scalar options
- Multi-section support (common, lint, format)
- Intelligent TOML merging preserving existing configuration
- Conflict detection (e.g., enabling and disabling same rule)
- Deprecated rule warnings
- Preview-by-default workflow (apply_configuration is explicit)
NESTED_CONFIG_SECTIONS = frozenset(("lint", "format"))

# Robocop configuration file names
CONFIG_NAMES = frozenset(("robocop.toml", "pyproject.toml", "robot.toml"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should CONFIG_NAMES be imported from config.py? In case there is change in one, so it does update the other.

"""
self._ensure_populated()
assert self._by_id is not None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to keep assert here? It looks like it can't be None as long as _ensure_populated is executed anyway

description = ""
if rule.docs:
first_line = rule.docs.strip().split("\n")[0].strip()
description = first_line[:200] if len(first_line) > 200 else first_line
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I read it correctly, it documentation is shorter than 200 we set description to first_line only? Why is that?

"description": description,
"severity": rule.severity.value,
"enabled": rule.enabled,
"deprecated": rule.deprecated,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will the deprecated rule be filtered out? For example user ask for rule that does X, and we have rule for that but it's deprecated. Ideally it shouldn't try to configure it.

return str(list(val)[:3]) + "..." if len(val) > 3 else str(list(val))
return str(val)
except (TypeError, ValueError):
return "(factory)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does (factory) means in this context?

@bhirsz
Copy link
Member

bhirsz commented Jan 11, 2026

@mikeleppane

Did you saw my comments? If youre busy its fine, but wanted to make sure I didnt bury the notifications when approving the changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants